/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
 */
package org.apache.rocketmq.common.protocol.heartbeat;

/**
 * 消息消费模式
 *
 * RocketMQ 支持两种消息模型：集群和广播。
 */
public enum MessageModel {

    /**
     * 广播模式消费消息
     * 一个消息,会给对应消费者组中的所有consumer去消费.
     */
    BROADCASTING("BROADCASTING"),

    /**
     * 集群模式消费消息
     * 一个消息,只会给1个consumer去消费(在同一个消费者组中的消费者).
     *
     * 备注:
     * - 相同的消费者组DefaultMQPushConsumer#consumerGroup的消费者只会消费订阅消息的分片，实现负载均衡；
     * - 这种消费模式下,会有[消费重试]机制: 获取consumer消费者组的重试topic,并且监听. 详见: DefaultMQPushConsumerImpl#copySubscription
     * - 集群模式下,多个消费者如何对消息队列进行负载呢?消息队列负载机制遵循一个通用的思想：
     *   一个消息队列同一时间只允许被一个消费者消费，一个消费者可以消费多个消息队列。
     *
     */
    CLUSTERING("CLUSTERING");

    private String modeCN;
    MessageModel(String modeCN) {
        this.modeCN = modeCN;
    }
    public String getModeCN() {
        return modeCN;
    }
}
